//
//  VGIMOCMessageCellFactory.m
//  IMTest
//
//  Created by 宋海胜 on 2019/4/22.
//  Copyright © 2019年 宋海胜. All rights reserved.
//


#import "VGIMOCMessageCellFactory.h"
#import "NIMMessageModel.h"
#import "NIMTimestampModel.h"
#import "NIMSessionAudioContentView.h"
#import "NIMKit.h"
#import "NIMKitAudioCenter.h"
#import "UIView+NIM.h"

@interface VGIMOCMessageCellFactory()

@end

@implementation VGIMOCMessageCellFactory

- (instancetype)init
{
    self = [super init];
    if (self) {
    }
    return self;
}

- (void)dealloc
{
    
}

- (VGIMOCMessageCell *)cellInTable:(UITableView*)tableView
                 forMessageMode:(NIMMessageModel *)model
{
    id<NIMCellLayoutConfig> layoutConfig = [[NIMKit sharedKit] layoutConfig];
    NSString *identity = [layoutConfig cellContent:model];
    VGIMOCMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    if (!cell) {
        NSString *clz = @"VGIMOCMessageCell";
        [tableView registerClass:NSClassFromString(clz) forCellReuseIdentifier:identity];
        cell = [tableView dequeueReusableCellWithIdentifier:identity];
    }
    return (VGIMOCMessageCell *)cell;
}

- (VGIMOCSessionTimestampCell *)cellInTable:(UITableView *)tableView
                            forTimeModel:(NIMTimestampModel *)model
{
    NSString *identity = @"time";
    VGIMOCSessionTimestampCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    if (!cell) {
        NSString *clz = @"VGIMOCSessionTimestampCell";
        [tableView registerClass:NSClassFromString(clz) forCellReuseIdentifier:identity];
        cell = [tableView dequeueReusableCellWithIdentifier:identity];
    }
    [cell refreshData:model];
    return (VGIMOCSessionTimestampCell *)cell;
}

@end

